/**
 * 教师表model
 * author:cjf
 * 现有字段:教师编号(teacher_id)描述(Integer、非空、唯一)、
 * 教师姓名(teacher_name)描述(String(100)、非空)、学校编号(school_id)描述(Integer、非空)
 * 教师用户名(teacher_uname)描述(String(100)、非空、唯一)、教师密码(teacher_pwd)描述(String(100)、非空)
 * 教师使用有效期(teacher_deadline)描述(Date、非空)
 */
import { DbContext } from '@codefree/badger/service'
const db = DbContext.Sequelize;

export type TeacherEntity = {
    teacher_id:Number,
    teacher_name:String,
    school_id:Number,
    teacher_uname:String,
    teacher_pwd:String,
    teacher_deadline:Date
}

const teacherEntity:TeacherEntity = {
    teacher_id:{
        type:db.INTEGER,
        unique:true,
        allowNull:false
    },
    teacher_name:{
        type:db.STRING(100),
        allowNull:false
    },
    school_id:{
        type:db.INTEGER,
        allowNull:false
    },
    teacher_uname:{
        type:db.STRING(100),
        allowNull:false,
        unique:true
    },
    teacher_pwd:{
        type:db.STRING(100),
        allowNull:false
    },
    teacher_deadline:{
        type:db.DATE,
        allowNull:false
    }
}

export default (sequelize) => {
    return {
        name: 'Teacher',
        define: sequelize.define("teacher", teacherEntity, DbContext.defaultOptions)
    }
}